package main

import (
	"fmt"
	"time"
)

func demoTime() {
	//获取当前时间
	now := time.Now()
	fmt.Printf("%v | %T\r\n", now, now)

	//通过now获取年月日，时分秒
	year := now.Year()

	fmt.Println(year, "年")
	// Month 默认是 英文的
	fmt.Println("月", int(now.Month()))
	fmt.Println("日", now.Day())
	fmt.Println("时", now.Hour())
	fmt.Println("分", now.Minute())
	fmt.Println("秒", now.Second())

	fmt.Println(now.Format("2006/01/02 15:04:05"))

}

func main() {
	demoTime()
	for i := 1; i < 100; i++ {
		fmt.Println(i)
		//time.Sleep(100 * time.Millisecond)
	}

	//unix 和 UnixNano
	fmt.Println("unix时间戳    ", time.Now().Unix())
	fmt.Println("unixNano时间戳", time.Now().UnixNano())

}
